using System.ComponentModel.DataAnnotations;

namespace SupplierCustomerManagement.Domain.Entities
{
    /// <summary>
    /// 折扣方案实体
    /// 代表为客户或供应商提供的折扣方案，包含方案信息、有效期、折扣项目等
    /// </summary>
    public class DiscountScheme : BaseEntity
    {
        /// <summary>
        /// 关联实体ID（客户ID或供应商ID）
        /// </summary>
        [Required]
        public int RelatedEntityId { get; set; }

        /// <summary>
        /// 关联实体类型（Customer/Supplier）
        /// </summary>
        [Required]
        [StringLength(50)]
        public string RelatedEntityType { get; set; }

        /// <summary>
        /// 方案名称
        /// </summary>
        [Required]
        [StringLength(200)]
        public string SchemeName { get; set; }

        /// <summary>
        /// 方案描述
        /// </summary>
        [Required]
        [StringLength(1000)]
        public string SchemeDescription { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        public DateTime StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime EndDate { get; set; }

        /// <summary>
        /// 折扣类型
        /// </summary>
        public string? DiscountType { get; set; }

        /// <summary>
        /// 折扣对象
        /// </summary>
        public string? DiscountTarget { get; set; }

        /// <summary>
        /// 方案类型
        /// </summary>
        public string? SchemeType { get; set; }

        /// <summary>
        /// 是否累进
        /// </summary>
        public bool IsProgressive { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string? ApprovedBy { get; set; }

        /// <summary>
        /// 财务
        /// </summary>
        public string? FinancedBy { get; set; }

        /// <summary>
        /// 制单人
        /// </summary>
        public string? PreparedBy { get; set; }

        /// <summary>
        /// 折扣方案项目集合（只读）
        /// </summary>
        public IReadOnlyCollection<DiscountSchemeItem> DiscountSchemeItems => _discountSchemeItems.AsReadOnly();

        /// <summary>
        /// 折扣方案项目集合（私有字段）
        /// </summary>
        private readonly List<DiscountSchemeItem> _discountSchemeItems = new();


        /// <summary>
        /// 折扣方案项目实体
        /// 代表折扣方案中的具体折扣项目，包含折扣类型、折扣对象、折扣方法等
        /// </summary>
        public class DiscountSchemeItem : BaseEntity
        {
            /// <summary>
            /// 折扣方案ID
            /// </summary>
            public int DiscountSchemeId { get; set; }

            /// <summary>
            /// 折扣类型
            /// </summary>
            public string DiscountType { get; set; }

            /// <summary>
            /// 折扣对象
            /// </summary>
            public string DiscountTarget { get; set; }

            /// <summary>
            /// 折扣项目
            /// </summary>
            public string DiscountItem { get; set; }

            /// <summary>
            /// 扣除金额
            /// </summary>
            public decimal Deduction { get; set; }

            /// <summary>
            /// 折扣方法
            /// </summary>
            public string DiscountMethod { get; set; }

            /// <summary>
            /// 是否累进
            /// </summary>
            public bool IsProgressive { get; set; }

            /// <summary>
            /// 上级客户
            /// </summary>
            public string? SuperiorCustomer { get; set; }

            /// <summary>
            /// 计提比率
            /// </summary>
            public decimal AccrualRate { get; set; }


        }
    }
} 